package com.burgeon.backend.SHOP.controller;

import com.burgeon.backend.SHOP.entity.Seckill;
import com.burgeon.backend.SHOP.service.SeckillService;
import com.burgeon.backend.stsutil.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@CrossOrigin
@RequestMapping("shop/seckill")
public class SeckillController extends BaseController {

    @Autowired
    private SeckillService seckillService;

    @RequestMapping("findseckill")
    public ResponseResult<List<Seckill>> findSeckill(Integer start,String message,HttpSession session) {
        String token = session.getAttribute("token").toString();
        List<Seckill> data = seckillService.findData(start,message,token);
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }

    @RequestMapping("showseckillnew")
    public ResponseResult<List<Seckill>> showSeckillnew(Integer start,HttpSession session) {
        String token = session.getAttribute("token").toString();
        List<Seckill> data = seckillService.getDatanew(start,token);
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }

    @RequestMapping("showseckill")
    public ResponseResult<List<Seckill>> showSeckill(HttpSession session) {
        String token = session.getAttribute("token").toString();
        List<Seckill> data = seckillService.getData(token);
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }

    /**
     * 测试
     * @return
     */
    @RequestMapping("testfindseckill")
    public ResponseResult<List<Seckill>> testfindseckill(Integer start,String message) {
        List<Seckill> data = seckillService.findData(start,message,"lfwd");
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }
    /**
     * 测试
     * @return
     */
    @RequestMapping("testshowseckillnew")
    public ResponseResult<List<Seckill>> testshowseckillnew(Integer start) {
        List<Seckill> data = seckillService.getDatanew(start,"lfwd");
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }

    /**
     * 测试
     * @return
     */
    @RequestMapping("testshowseckill")
    public ResponseResult<List<Seckill>> testshowseckill() {
//        String token = session.getAttribute("token").toString();
        List<Seckill> data = seckillService.getData("lfwd");
        return new ResponseResult<List<Seckill>>(SUCCESS,data);
    }

}
